package com.jingwu.example.repository;

import cn.hutool.core.util.RandomUtil;
import com.jingwu.example.pojo.entity.ActivityDO;
import com.jingwu.example.pojo.entity.ActivityStageAwardDO;
import com.jingwu.example.pojo.entity.ActivityStageDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * @author 菁芜
 * @since 2021/7/22 - 20:17
 */
@Slf4j
@Repository
public class ActivityRepository {

    public ActivityDO selectById(String id) {
        ActivityDO entity = new ActivityDO();
        entity.setId(id);
        entity.setName(RandomUtil.randomString(10));
        return entity;
    }

    public Boolean exist(String id, String stageId, String userId) {
        return RandomUtil.randomBoolean();
    }

    public ActivityStageDO selectStage(String id, String stageId) {
        return null;
    }

    public Boolean saveAward(ActivityStageAwardDO entity) {
        final boolean result = RandomUtil.randomBoolean();
        log.info("保存结果：{}", result);
        function();
        return result;
    }

    private void function() {
        log.info("抛了异常");
        throw new NullPointerException();
    }
}
